package run.bottle.gof23.single;

// 懒汉式单例
public class LazyMan {
    private LazyMan(){

    }

    private static LazyMan lazyMan;

    //双重检测 DCL懒汉式
    public static LazyMan getInstance() {

        if (lazyMan == null) {
            synchronized (LazyMan.class) {
                if (lazyMan == null) {
                    lazyMan = new LazyMan();  //不是原子性操作 延申阅读：http://blog.bottle.run/archives/volatile
                }
            }
        }
        return lazyMan;
    }

}
